<div class="container">
		<h1>Thống kê</h1>
<script type="text/javascript">
 $(function() {
 });
</script>
		<?php echo form_open(current_url()); ?>	
	Chọn: <?php echo $combobox_cats;?>
	<input id="statistics_dt" type="text" name="statistics_dt" value="<?php echo $time;?>"  />
	<input type="submit" value="Liệt kê" />
	<?php echo form_close(); ?>
	
<table id="hor-minimalist-b">
	<tr>
	  <?php
				$stt = 1;
				echo "<th>Stt</th>";
                foreach( $rules as $i ){
                    if( in_array( $i[ 'field_id' ], $master_limited  ) ){
						if(isset($i[ 'width' ]))
							$width = "width = '".$i[ 'width' ]."'";
						else
							$width = "";
                        echo "<th $width>". $i[ 'label' ]."</th>";
					}
                }
            ?>
       
	</tr>
	 <?php
			
                for( $i = 0; $i < count( $results ); $i++ ){
                    echo "<tr>";
							echo "<td>$stt</td>";
                            foreach( $rules as $item ){
                           	    if( $item[ 'field_id' ] != "Image_ID" && in_array( $item[ 'field_id' ], $master_limited ) ){	        
         			                echo "<td>";
									if($item[ 'control' ] == "time")
										echo date("d/m/y",$results[ $i ][ $item[ 'field_id' ] ]);
									else if($item[ 'control' ] == "phieu" && $results[ $i ][ $item[ 'field_id' ] ])
										echo $results[ $i ][ $item[ 'field_id' ] ]." suat(tang ".$results[$i]['Tang']." suat)";
									else if($item[ 'control' ] == "suat" && $results[ $i ][ $item[ 'field_id' ] ]) 
										echo $results[ $i ][ $item[ 'field_id' ] ]." suat";
									else if($item[ 'control' ] == "vnd") 
										echo formatcurrency($results[ $i ][ $item[ 'field_id' ] ] * 1000);
									else echo $results[ $i ][ $item[ 'field_id' ] ];
									
            						echo "</td>";						
    					}?>
                         
                        <?php 
                            }
                      $stt++; 
                    echo "</tr>";
                }
            ?>
		
			<tr style="font-weight:bold; font-size:16px;">
				<td colspan="5" valign="right" style="text-align:right;">Tổng cộng</td>
				<td colspan="4" valign="right" style="text-align:right;"><?php echo formatcurrency($thanhtien*1000);?></td>
			</tr>
				<tr style="font-weight:bold; font-size:16px;">
				<td colspan="5" valign="right" style="text-align:right;">Tiền típ</td>
				<td colspan="4" valign="right" style="text-align:right;"><?php echo formatcurrency($tientip*1000);?></td>
			</tr>
			</tr>
				<tr style="font-weight:bold; font-size:16px;">
				<td colspan="5" valign="right" style="text-align:right;">Tiền dich vu</td>
				<td colspan="4" valign="right" style="text-align:right;"><?php echo formatcurrency($sum_dv*1000);?></td>
			</tr>
			<tr style="font-weight:bold; font-size:16px;">
				<td colspan="5" valign="right" style="text-align:right;">Còn lại</td>
				<td colspan="4" valign="right" style="text-align:right;"><?php echo formatcurrency($thanhtien*1000 - $tientip*1000 - $sum_dv*1000);?></td>
			</tr>
	</table><h1>Tien dich vu</h1>
<table id="hor-minimalist-b">
<tr>
<th>Stt</th>
<th>Ten NV</th>
<th>Tien dich vu </th>
</tr>
<tr>
<?php 
$i=1;
foreach($tiendv as $item){
?>
<td><?php echo $i;?></td>
<td><?php echo $item['Personal_ID'];?></td>
<td style="text-align:right;"><?php echo formatcurrency($item['Price_Serv']*1000);?></td>
</tr>
<?php $i++;} ?>
<tr>
<td colspan="2">Tong tien dich vu</td>
<td style="text-align:right;"><?php echo formatcurrency($sum_dv*1000);?></td>
</tr>
</table>
</div>

